package gererg;

import java.util.ArrayList;
import java.util.List;

/**
 * @author leon(liangzou0318@gmail.com)
 * @date 2012-10-30
 * @filaname MaxMin.java
 */
public class MaxMin {
	int max=0,min=0;  
  public List<Integer> getMaxMin(int i,int j,int a[]){
	// int a[]={3,4,5,6,7};
	  System.out.println("  erger"+a[1]);
	  List<Integer> b=new ArrayList<Integer>();
	  
	  if (i==j){
		  System.out.println("IF  erger"+a[i]);
		  max=a[i];
		  min=a[i];
	  }
	  else if(i==j-1){
		  if (a[i]<a[j]){ 
			  max=a[j];
			  min=a[i];
		  }
		  else{
			  max=a[i];
			  min=a[j];
		  }
	  }
	  else{
		  int m=i+(j-i)/2;
		  System.out.println("m:"+m);
		  System.out.println(" fwe erger");
		  getMaxMin(i,m,a);
		  
		//  min=getMaxMin(i,m,a).get(1);
		  System.out.println("  Rerger");
		   getMaxMin(m+1,j,a);
		  
	  }
	  System.out.println("max:"+max+"   min:"+min);
	  b.add(max);
	  b.add(min);
	return b;
	  
  }
  public static void main(String args[]){
	  List b=new ArrayList();
	  int a[]={4,10,6,7,8,9};
	  MaxMin mm=new MaxMin();
	  b=mm.getMaxMin(0,a.length-1, a);
	  System.out.println(b.get(0)+"  "+b.get(1));
	  }
	  
  }
   
      

